﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;
using Common;
using DAO;

public partial class Admin_Pages_ChangePassword : BasePage
{
    BUS_WRUSER _busUser = new BUS_WRUSER();
    private Encrypt _objEncrypt = new Encrypt();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        string id = Session["userid"].ToString();
        WRUSER user = new WRUSER();
        user = _busUser._GetObject(p=>p.ID == Convert.ToInt32(id) && p.Password == _objEncrypt.Mahoa(txtPasswordOld.Text));
        if (user != null)
        {
            _busUser._Update(Convert.ToInt32(id), _objEncrypt.Mahoa(txtPasswordNew.Text));
            Response.Redirect("~/Admin/Pages/login.aspx");
        }
        else
        {
            WebMsgBox.Show("Mật khẩu cũ không đúng!");
        }
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Admin/Pages/login.aspx");
    }
}